//
//  DYZXViewController.m
//  HBuilder
//
//  Created by 黄德玉 on 2019/11/2.
//  Copyright © 2019 DCloud. All rights reserved.
//

#import "DYZXViewController.h"
#import "DYIMChatNavView.h"
#import "Masonry.h"
#import "DYGlobal.h"
#import "UIView+MBProgressHUD.h"
#import "DYZXView.h"
#import "EBHNetWorkingManager.h"


@interface DYZXViewController ()

@property (nonatomic ,strong) DYIMChatNavView * navBar;
@property (nonatomic, strong) DYZXView * contentView;

@end

@implementation DYZXViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.view addSubview:self.navBar];
    CGFloat height = 64.0;
    if ([DYGlobal isNotchScreen]) {
        height = 88.f;
    }
    [self.navBar mas_makeConstraints:^(MASConstraintMaker *make) {
          make.left.top.right.equalTo(self.view);
          make.height.equalTo(@(height));
      }];
    [self.view addSubview:self.contentView];
    [self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.bottom.right.equalTo(self.view);
        make.top.equalTo(self.navBar.mas_bottom);
    }];
    self.navBar.titleLabel.text = @"咨询费设置";
    self.view.backgroundColor = [UIColor whiteColor];
    
    [self loadData];
}



#pragma mark - 网络请求

- (void)loadData{
    __weak typeof(self)weakSelf = self;
    [EBHNetWorkingManager queryWithPath:@"/sapi/hcp/servicePrice" pars:@{@"consumer":self.targetId} callback:^(NSError * _Nonnull error, id  _Nonnull response) {
        if (error) {
            [weakSelf.view showHUDMessage:@"查询失败"];
            return;
        }
        id money = [response objectForKey:@"price"];
        NSString * value = [[NSString alloc] initWithFormat:@"￥%@",money];
        weakSelf.contentView.moneyLbl.text = value;
    }];
}


- (DYIMChatNavView *)navBar{
   if (!_navBar) {
          _navBar = [[DYIMChatNavView alloc] init];
          __weak typeof(self)weakSelf = self;
          _navBar.itemClicked = ^(NSInteger tag) {
              [weakSelf.navigationController popViewControllerAnimated:YES];
          };
          if (self.title) {
              _navBar.titleLabel.text = self.title;
          }
      }
      return _navBar;
}

- (DYZXView *)contentView{
    if (!_contentView) {
        _contentView = [DYZXView new];
        _contentView.consumer = self.targetId;
    }
    return _contentView;
}


@end
